import mongoose from '../config/DBHelper'

const Schema = mongoose.Schema

const UserSchema = new Schema({
  _id: String,
  mobile: String,
  username: String,
  unread: Number,
  nickname: String,
  roles: Object,
  roleid: String,
  organs: Object,
  favs: Number,
  location: String,
  isVip: Number,
  gender: Number,
  pic: String,
  count: Number,
  status: String,
  regmark: String,
  password: String,
  created: String,
  __v: Number,
  isSign: Number,
})

UserSchema.statics = {
  findByID: function (id) {
    return this.findOne({ _id: id }, {
      password: 0, username: 0, mobile: 0
    })
  }
}
const UserModel = mongoose.model('users', UserSchema)

export default UserModel
